require 'observer'

module	Informer
	include Observable

	# States
	UNDEFINED, OK, WARN, ERROR = :undefined, :ok, :warn, :error
	STATES = [UNDEFINED, OK, WARN, ERROR]

	def state?
		@state= UNDEFINED unless defined? @state
	  return @state
	end

	def state= (value)
#		if !defined?(@state) or	 (STATES.index(value) > STATES.index(@state))
			@state=value
#		end
	end

	def add_notice (notice)
		@notice =[] unless defined? @notice
	  @notice << notice
		self.changed
		self.notify_observers(self)
		return self
	end

	def notice?
		@notice =[] unless defined? @notice		
		return @notice
	end

	def clear!
		@state = UNDEFINED
		@notice = []
		self.changed
		self.notify_observers(self)
		return self
	end
	
end
